package com.isesol.ime.entity;

import com.fasterxml.jackson.annotation.*;
import com.isesol.ime.*;
import com.isesol.orm.jpa.*;

import javax.persistence.*;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.*;

/**
 * 报文管理
 *
 * @author Wang Jun
 */
@Entity
@Table(name = "message", catalog = Constant.DB_SCHEME_MT)
@Access(AccessType.FIELD)
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Message extends IdEntity<Long>{

	/**
	 * 报文id
	 */
	private String msgId;

	/**
	 * 报文名称
	 */
	private String msgName;

	/**
	 * 报文号
	 */
	private String msgNumber;

	/**
	 * 机床类型
	 */
	@ManyToOne
	@JoinColumn(name = "TYPE_ID")
	private Type type;

	/**
	 * 报文已选参数
	 */
	@OneToMany(cascade = CascadeType.ALL,orphanRemoval = true,fetch = FetchType.EAGER,mappedBy = "message")
	private Set<MessageParam> msgParams;

	/**
	 * 规则类型
	 */
	@ManyToOne
	@JoinColumn(name = "RULE_TYPE")
	private RuleType ruleType;

	/**
	 * 规则
	 */
	private String rule;

	/**
	 * 是否反馈
	 */
	private boolean feedback;

	/**
	 * 是否加密
	 */
	private boolean  encrypt;

	/**
	 * 是否永久保存
	 */
	private boolean preservation;

	/**
	 * 备注
	 */
	private String memo;

	/**
	 * 使用状态
	 */
	private String usingStatus;

	/**
	 * 当前状态
	 */
	private String status;

	public String getMsgId(){

		return msgId;
	}

	public void setMsgId(String msgId){

		this.msgId = msgId;
	}

	public String getMsgName(){

		return msgName;
	}

	public void setMsgName(String msgName){

		this.msgName = msgName;
	}

	public Type getType(){

		return type;
	}

	public void setType(Type type){

		this.type = type;
	}

	public Set<MessageParam> getMsgParams(){

		return msgParams;
	}

	public void setMsgParams(Set<MessageParam> msgParams){

		this.msgParams = msgParams;
	}

	public RuleType getRuleType(){

		return ruleType;
	}

	public void setRuleType(RuleType ruleType){

		this.ruleType = ruleType;
	}

	public boolean isFeedback(){

		return feedback;
	}

	public void setFeedback(boolean feedback){

		this.feedback = feedback;
	}

	public boolean isEncrypt(){

		return encrypt;
	}

	public void setEncrypt(boolean encrypt){

		this.encrypt = encrypt;
	}

	public boolean isPreservation(){

		return preservation;
	}

	public void setPreservation(boolean preservation){

		this.preservation = preservation;
	}

	public String getMemo(){

		return memo;
	}

	public void setMemo(String memo){

		this.memo = memo;
	}

	public String getMsgNumber(){

		return msgNumber;
	}

	public void setMsgNumber(String msgNumber){

		this.msgNumber = msgNumber;
	}

	public String getRule(){

		return rule;
	}

	public void setRule(String rule){

		this.rule = rule;
	}

	public String getStatus(){

		return status;
	}

	public void setStatus(String status){

		this.status = status;
	}

	public String getUsingStatus(){

		return usingStatus;
	}

	public void setUsingStatus(String usingStatus){

		this.usingStatus = usingStatus;
	}
}
